home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
TCL1
/
__MANDEL
/
MANDELBR
/
CPIXMAP.C
< prev
next >
Wrap
Text File
|
1992-05-31
|
3KB
|
172 lines
/******************************************************************************
CPixMap.c
The PixMap Class
SUPERCLASS = CBitMap
******************************************************************************/
#include "Global.h"
#include "CPixMap.h"
#include "TCLUtilities.h"
#include "CDesktop.h"
#include "LongQD.h"
extern CDesktop *gDesktop;
PicHandle gPixPictH;
void CPixMap::IPixMap(Rect aBoundsRect, short aDepth)
{
GrafPtr aSavedPortP;
GDHandle aSavedDeviceH;
GWorldPtr aGWorldP;
GetGWorld(&aSavedPortP, &aSavedDeviceH);
FailOSErr(NewGWorld(&aGWorldP, aDepth, &aBoundsRect, NULL, NULL, 0));
SetGWorld(aSavedPortP, aSavedDeviceH);
itsGWorldP = aGWorldP;
itsBoundsRect = aBoundsRect;
itsXferMode = srcCopy;
}
void CPixMap::Dispose()
{
ForgetPtr(itsCQDProcs);
if (itsGWorldP)
DisposeGWorld(itsGWorldP);
inherited::Dispose(); /* Pass message on to superclass */
}
void CPixMap::SetXferMode(short theMode)
{
itsXferMode = theMode;
}
short CPixMap::GetXferMode(void)
{
return itsXferMode;
}
void CPixMap::GetBounds(
Rect *theBounds)
{
*theBounds = itsBoundsRect;
/* Return copy of instance variable */
}
short CPixMap::GetWidth(void)
{
return itsBoundsRect.right - itsBoundsRect.left;
}
short CPixMap::GetHeight(void)
{
return itsBoundsRect.bottom - itsBoundsRect.top;
}
void CPixMap::CopyFrom(
LongRect *fromRect,
LongRect *toRect,
RgnHandle maskRgn)
{
PixMapHandle aPixMapH = GetPixMapHandle();
if (LockPixels(aPixMapH))
{
LCopyBits((BitMap *)*aPixMapH,
&thePort->portBits,
fromRect, toRect, itsXferMode, maskRgn);
UnlockPixels(aPixMapH);
}
}
void CPixMap::BeginDrawing()
{
GrafPtr aSavedPortP;
GDHandle aSavedDeviceH;
if (! LockPixels(GetPixMapHandle()))
Failure(QDError(), 0);
GetGWorld(&aSavedPortP, &aSavedDeviceH);
SetGWorld(itsGWorldP, NULL);
itsSavedPortP = aSavedPortP;
itsSavedDeviceH = aSavedDeviceH;
}
void CPixMap::EndDrawing()
{
SetGWorld(itsSavedPortP, itsSavedDeviceH);
UnlockPixels(GetPixMapHandle());
}
PixMapHandle CPixMap::GetPixMapHandle(void)
{
return GetGWorldPixMap(itsGWorldP);
}
Ptr CPixMap::GetBaseAddr(void)
{
return GetPixBaseAddr(GetPixMapHandle());
}
short CPixMap::GetRowBytes(void)
{
return (**GetPixMapHandle()).rowBytes & 0x1FFF;
}
short CPixMap::GetPixelSize(void)
{
return (**GetPixMapHandle()).pixelSize;
}
PicHandle CPixMap::GetPicHandle(void)
{
PicHandle aPictH;
PixMapHandle aPixMapH;
Rect aBoundsRect;
BeginDrawing();
aBoundsRect = itsBoundsRect;
aPixMapH = GetPixMapHandle();
gPixPictH = NULL;
gPixPictH = OpenPicture(&aBoundsRect);
CopyBits(*aPixMapH, *aPixMapH, &aBoundsRect, &aBoundsRect, srcCopy, NULL);
ClosePicture();
EndDrawing();
return gPixPictH;
}
void CPixMap::SetPutPicProc(ProcPtr thePutPicProc)
{
BeginDrawing();
UseStdProcs();
itsGWorldP->grafProcs = itsCQDProcs;
itsCQDProcs->putPicProc = thePutPicProc;
EndDrawing();
}
void CPixMap::UseStdProcs(void)
{
itsCQDProcs = (CQDProcs *)NewPtr(sizeof(CQDProcs));
FailNIL(itsCQDProcs);
SetStdCProcs(itsCQDProcs);
}
void CPixMap::ResetStdProcs(void)
{
ForgetPtr(itsCQDProcs);
itsGWorldP->grafProcs = NULL;
}